import Vue from 'vue'
import axios from 'axios'
import mavonEditor from 'mavon-editor'
// 可以通过 mavonEditor.markdownIt 获取解析器markdown-it对象
import 'mavon-editor/dist/css/index.css'

import App from './App'
import router from './router'
import store from './store'
import NeDB from 'nedb'

Vue.use(mavonEditor)

const db = new NeDB({
  filename: '/data/save.db',
  autoload: true
})
db.find({
  name: 'openFileRecord'
}, (err, data) => {
  if (err) throw err
  if (data.length === 0) {
    db.insert({
      name: 'openFileRecord',
      recordList: []
    }, (err, data) => {
      if (err) throw err
      console.log(data)
    })
  }
})
Vue.prototype.db = db

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.http = Vue.prototype.$http = axios
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  components: { App },
  router,
  store,
  template: '<App/>'
}).$mount('#app')
